//
//  staffTimeCell.m
//  QRMaster
//
//  Created by myApple on 15/7/28.
//  Copyright (c) 2015年 myApple. All rights reserved.
//

#import "staffTimeCell.h"

@interface staffTimeCell()
{
    UIImageView * timeImgView;
    UILabel * timeLabel;
    UILabel * weekLabel;
    NSArray * weekData;
}

@end

@implementation staffTimeCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self prepareView];
        weekData = @[NSLocalizedString(@"Sunday", nil),NSLocalizedString(@"Monday", nil),NSLocalizedString(@"Tuesday", nil),NSLocalizedString(@"Wednesday", nil),NSLocalizedString(@"Thursday", nil),NSLocalizedString(@"Friday", nil),NSLocalizedString(@"Saturday", nil)];
    }
    return self;
}

-(void)prepareView
{
    float x = 16;
    float y = (56 - 28)/2.0;
    float width = 28;
    float height = 28;
    
    timeImgView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];
    [self.contentView addSubview:timeImgView];
    
    x += width + 16;
    width = UI_SCREEN_WIDTH - x - 32;
    y = 8;
    height = 20;
    timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, height)];
    timeLabel.font = [UIFont systemFontOfSize:14.0];
    [self.contentView addSubview:timeLabel];
    
    
    y += height;
    height = 20;
    width = UI_SCREEN_WIDTH - x;
    weekLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, y, width, height)];
    weekLabel.font = [UIFont systemFontOfSize:12.0];
    weekLabel.textColor = UIColorFromRGB(0x727272);
    [self.contentView addSubview:weekLabel];
}


-(void)setWeekInfo:(NSString *)weekInfo
{
    _weekInfo = weekInfo;
    NSArray * weekInfoData = [weekInfo componentsSeparatedByString:@","];
    NSMutableString * weekString = [[NSMutableString alloc]init];
    for (int i = 0 ; i < weekInfoData.count; i ++) {
        [weekString appendString:weekData[[weekInfoData[i] integerValue]]];
         [weekString appendString:@" "];
    }
         weekLabel.text = weekString;
}

-(void)setBeginTime:(NSString *)beginTime
{
    _beginTime = beginTime;
}

-(void)setEndTime:(NSString *)endTime
{
    _endTime = endTime;
    timeLabel.text = [NSString stringWithFormat:@"%@~%@",_beginTime,_endTime];
}

-(void)setTimeImage:(UIImage *)timeImage
{
    _timeImage = timeImage;
    timeImgView.image = timeImage;
}

-(void)setTimeId:(NSString *)timeId
{
    _timeId = timeId;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
